package com.android.demos.module.wificonnect.adapter;

import android.content.Context;
import android.net.wifi.ScanResult;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.aaron.android.framework.base.widget.recycleview.BaseRecycleViewAdapter;
import com.aaron.android.framework.base.widget.recycleview.BaseRecycleViewHolder;
import com.android.demos.R;

/**
 * Created on 16/11/1.
 *
 * @author aaron.huang
 * @version 1.0.0
 */
public class WifiListAdapter extends BaseRecycleViewAdapter<WifiListAdapter.WifiViewHolder, ScanResult> {

    public WifiListAdapter(Context context) {
        super(context);
    }

    @Override
    protected WifiViewHolder createViewHolder(ViewGroup parent) {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.viewholder_wifi_item, parent, false);
        return new WifiViewHolder(view);
    }

    class WifiViewHolder extends BaseRecycleViewHolder<ScanResult> {

        private TextView mWifiNameTextView;

        public WifiViewHolder(View itemView) {
            super(itemView);
            mWifiNameTextView = (TextView) itemView.findViewById(R.id.wifi_textView);
        }

        @Override
        public void bindViews(ScanResult object) {
            if (object == null) {
                return;
            }
            mWifiNameTextView.setText(object.SSID);
        }
    }
}
